package com.leyou.order.config;

import com.leyou.common.utils.IdWorker;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 处理请求和响应的方法
 *
 * @version V1.0
 * @package com.leyou.order.config
 * @description:
 * @author: pc
 * @date: 2019/7/13 20:18
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "ly.worker")
public class IdWorkerConfig {

    private long workerId;// 当前机器id

    private long dataCenterId;// 序列号

    @Bean
    public IdWorker idWorker() {
        return new IdWorker(workerId, dataCenterId);
    }

    public long getWorkerId() {
        return workerId;
    }

    public void setWorkerId(long workerId) {
        this.workerId = workerId;
    }

    public long getDataCenterId() {
        return dataCenterId;
    }

    public void setDataCenterId(long dataCenterId) {
        this.dataCenterId = dataCenterId;
    }
}
